package com.ruoyi.game.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.game.domain.GameEcpmRecord;
import com.ruoyi.game.service.IGameEcpmRecordService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * ECPM记录Controller
 * 
 * @author ruoyi
 * @date 2024-03-22
 */
@RestController
@RequestMapping("/game/ecpmRecord")
public class GameEcpmRecordController extends BaseController
{
    @Autowired
    private IGameEcpmRecordService gameEcpmRecordService;

    /**
     * 查询ECPM记录列表
     */
    @PreAuthorize("@ss.hasPermi('game:ecpmRecord:list')")
    @GetMapping("/list")
    public TableDataInfo list(GameEcpmRecord gameEcpmRecord)
    {
        startPage();
        List<GameEcpmRecord> list = gameEcpmRecordService.selectGameEcpmRecordList(gameEcpmRecord);
        return getDataTable(list);
    }

    /**
     * 导出ECPM记录列表
     */
    @PreAuthorize("@ss.hasPermi('game:ecpmRecord:export')")
    @Log(title = "ECPM记录", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, GameEcpmRecord gameEcpmRecord)
    {
        List<GameEcpmRecord> list = gameEcpmRecordService.selectGameEcpmRecordList(gameEcpmRecord);
        ExcelUtil<GameEcpmRecord> util = new ExcelUtil<GameEcpmRecord>(GameEcpmRecord.class);
        util.exportExcel(response, list, "ECPM记录数据");
    }

    /**
     * 获取ECPM记录详细信息
     */
    @PreAuthorize("@ss.hasPermi('game:ecpmRecord:query')")
    @GetMapping(value = "/{ecpmId}")
    public AjaxResult getInfo(@PathVariable("ecpmId") Long ecpmId)
    {
        return success(gameEcpmRecordService.selectGameEcpmRecordByEcpmId(ecpmId));
    }

    /**
     * 新增ECPM记录
     */
    @PreAuthorize("@ss.hasPermi('game:ecpmRecord:add')")
    @Log(title = "ECPM记录", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody GameEcpmRecord gameEcpmRecord)
    {
        return toAjax(gameEcpmRecordService.insertGameEcpmRecord(gameEcpmRecord));
    }

    /**
     * 修改ECPM记录
     */
    @PreAuthorize("@ss.hasPermi('game:ecpmRecord:edit')")
    @Log(title = "ECPM记录", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody GameEcpmRecord gameEcpmRecord)
    {
        return toAjax(gameEcpmRecordService.updateGameEcpmRecord(gameEcpmRecord));
    }

    /**
     * 删除ECPM记录
     */
    @PreAuthorize("@ss.hasPermi('game:ecpmRecord:remove')")
    @Log(title = "ECPM记录", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ecpmIds}")
    public AjaxResult remove(@PathVariable Long[] ecpmIds)
    {
        return toAjax(gameEcpmRecordService.deleteGameEcpmRecordByEcpmIds(ecpmIds));
    }
}
